package com.example.usercenter.exception;

import com.example.usercenter.common.ErrorCode;


/**
 * @projectName: user-center
 * @package: com.example.usercenter.exception
 * @className: BusinessException
 * @author: Dengke。Zhao
 * @description: TODO
 * @date: 2024/6/24 16:36
 * @version: 1.0
 */
public class BusinessException extends RuntimeException {

    private final int code;

    private final String description;


    public BusinessException(String message, int code, String description) {
        super(message);
        this.code = code;
        this.description = description;
    }

    public BusinessException(ErrorCode errorCode) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = errorCode.getDescription();
    }

    public BusinessException(ErrorCode errorCode, String description) {
        super(errorCode.getMessage());
        this.code = errorCode.getCode();
        this.description = description;
    }

    public int getCode() {
        return code;
    }

    public String getDescription() {
        return description;
    }
}
